package com.example.config;

import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.Arrays;

/**
 * 缓存配置类
 */
@Configuration
@EnableCaching
@EnableScheduling
public class CacheConfig {

    /**
     * 配置缓存管理器
     */
    @Bean
    public CacheManager cacheManager() {
        SimpleCacheManager cacheManager = new SimpleCacheManager();
        cacheManager.setCaches(Arrays.asList(
            // 数据库元数据缓存
            new ConcurrentMapCache("dbSchema"),
            // 表结构缓存
            new ConcurrentMapCache("tableMetadata"),
            // 列信息缓存
            new ConcurrentMapCache("columnMetadata")
        ));
        return cacheManager;
    }
} 